import Vue from "vue";
import App from "./App";
import router from "./router";
import "./assets/iconfont/iconfont"; //使用svg图标
import {
    fatch
} from "./http";
import store from "./vuex/store";
import * as filters from "./util/filters";

import agent from "./vuex/store.js";

Vue.config.productionTip = false;

Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key]);
});

// 引入Element UI
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);

// 设置http请求
Vue.prototype.$axios = fatch;

// 引入mint-UI
import Mint from "mint-ui";
Vue.use(Mint);

// 引入vuex
import Vuex from "vuex";
Vue.use(Vuex);

// 全局路由设置
router.beforeEach((to, from, next) => {
    let data = agent.state.agent.clearDataArr;
    data.forEach(function (item, index) {
        store.commit("agent/CLEAR_All", {
            key: item,
            value: ""
        });
    });

    // 定义标题
    document.title = to.name;
    next();
});

/* eslint-disable no-new */
new Vue({
    el: "#app",
    router,
    store,
    components: {
        App
    },
    template: "<App/>"
});
